import LGXCOM from '../common/common.js'
import baseunitgrah from './baseunitgrah.js'
import { CoordTRFUtil } from '../common/tools/coordtool.js'
import Coord from '../common/struct/coord.js'
import ActPkg from '../graph/action/arcaction.js'
import UtilFuncs from '../common/tools/utilfuncs.js'
var funcs = UtilFuncs.UtilFuncs;

import GlobalConst from '../common/globalConst.js'
var global = GlobalConst.GlobalConst;
import {FillUtil} from '../graph/paintutil/fillutil.js'
import {Strokeutil} from '../graph/paintutil/strokeutil.js'
import absorbCirclePos from '../service/absorbpossvc/absorboncirclepos.js'
var AbsorbPosInCircle = absorbCirclePos.AbsorbCirclePos;

import {LGXEnums}  from '../common/sysenum.js'

import arc from '../common/struct/basestruct/arc.js'
var arcUnit = arc.Arc;

import { CommonPaintUtil } from './paintutil/compaintutil.js'
import { PositionUtil } from '../common/tools/positionutil.js'
import { GlobalVar } from '../common/globalvar.js'



class ArcGraph extends baseunitgrah.BaseUnitGraph {
    constructor(type) {
        super(type);
        this.m_graphType = LGXEnums.LGXGraphType.ArcGraph_type;
        var p = new Coord.ArcPos();
        this.setPos(p);
        var action = new ActPkg.ArcAction(this);
        this.setActionSvc(action);
        this.close = false;
        this.stPoint = new LGXCOM.LGXPoint();
        this.midPoint = new LGXCOM.LGXPoint();
        this.endPoint = new LGXCOM.LGXPoint();

        this.plotMode = GlobalVar.arcPlotMode;
        this.disAuxPoint = new LGXCOM.LGXPoint();
        this.midCtrlPoint = new LGXCOM.LGXPoint();//由外部类输入或者控制的中间点
    }

    display(map, mapInfo,forClip) {
        // console.log("arc display ****************");
        if (this.getFinish() == 0 && this.getMouseDownTime() == 1) {
            this.disAuxline(map, mapInfo);
            return;
        }

        var postion = this.getPos();
        var scaling = mapInfo.getLenthDisScale();
        var disRadius = scaling * postion.radius;
        var x = postion.x;
        var y = postion.y;
        var cntpt = { x, y };
        var p1 = CoordTRFUtil.world2Screen(cntpt, mapInfo);

        var cntWorldPT = this.getZone().getCnt();
        var cntScreenPT = CoordTRFUtil.world2Screen(cntWorldPT, mapInfo);
        let rotv = 0;//this.getRadAngle();

        if (isNaN(postion.stAngle) || isNaN(postion.endAngle)) {
            console.log("nul&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
            // alert("error arc data");
            if (!this._modifing)
                this.setUseful(0);
            return;
        }

        let stAngleRad = Math.PI * 2 - funcs.degree2Radian(postion.stAngle);
        let endAngleRad = Math.PI * 2 - funcs.degree2Radian(postion.endAngle);

        map.save();
        map.lineWidth = this._lineDef.lineWidth * scaling;
        map.translate(cntScreenPT.x, cntScreenPT.y);
        map.rotate(-rotv);
        map.translate(-cntScreenPT.x, -cntScreenPT.y);
        map.beginPath();
        map.arc(p1.x, p1.y, disRadius, stAngleRad, endAngleRad, postion.antiClockWise);
        Strokeutil.active(this._lineDef, this, map, mapInfo);
        if (this.close) {
            map.closePath();
            if (!forClip){
                FillUtil.active(this._fillDef, map, this, mapInfo, false);
            }
        }
        map.restore();

        super.displayGraphScope(map, mapInfo);
        this.displayFeaturePoint(map, mapInfo);
        if (this._highLight) {
            CommonPaintUtil.disPointCross(cntpt, GlobalVar.highlightColor.toHexString(), map, mapInfo);
        }
        if (this.getFinish() == 0) {
            this.displayPlotCtrlPoint(map, mapInfo);
        }
    }

    displayPlotCtrlPoint(map, mapInfo) {
        let pt = CoordTRFUtil.world2Screen(this.stPoint, mapInfo);
        super.drawFocusPoint(map, pt.x, pt.y, "#ff00ff");

        pt = CoordTRFUtil.world2Screen(this.endPoint, mapInfo);
        super.drawFocusPoint(map, pt.x, pt.y, "#ff00ff");

        pt = CoordTRFUtil.world2Screen(this.midCtrlPoint, mapInfo);
        super.drawFocusPoint(map, pt.x, pt.y, "#ff00ff");
    }

    disAuxline(map, mapInfo) {
        if (this.plotMode == LGXEnums.ArcPlotMode.CenterAngleMode) {
            this.disCnt2StAuxline(map, mapInfo);
        }
        else if (this.plotMode == LGXEnums.ArcPlotMode.Point3Mode) {
            this.disSt2MidAuxline(map, mapInfo);
        }
    }

    disSt2MidAuxline(map, mapInfo) {
        var p1 = CoordTRFUtil.world2Screen(this.stPoint, mapInfo);
        var p2 = CoordTRFUtil.world2Screen(this.midCtrlPoint, mapInfo);

        map.save();
        map.lineWidth = 1;
        map.beginPath();
        map.moveTo(p1.x, p1.y);
        map.lineTo(p2.x, p2.y);
        Strokeutil.active(this._lineDef, this, map, mapInfo);
        map.restore();
    }

    disCnt2StAuxline(map, mapInfo) {
        var postion = this.getPos();
        var p1 = CoordTRFUtil.world2Screen(postion, mapInfo);
        var p2 = CoordTRFUtil.world2Screen(this.disAuxPoint, mapInfo);

        map.save();
        map.lineWidth = 1;
        map.beginPath();
        map.moveTo(p1.x, p1.y);
        map.lineTo(p2.x, p2.y);
        Strokeutil.active(this._lineDef, this, map, mapInfo);
        map.restore();
    }

    displayFeaturePoint(map, mapInfo) {
        if (this._selected) {
            this.displayControlPoint(map, mapInfo);
        }
    }

    disInSymbol(transformInfo, map, mapInfo,forClip) {
        // if (mapInfo){
        //     return ;
        // }
        var postion = this.getPosCopy();
        let arcPtInfo = funcs.getArcControlPoint(postion);
        let arcVectInfo = funcs.getArcStAndEndVector(postion);
        let radAngle = this.getRadAngle();

        let cnt = CoordTRFUtil.transLocalPt2World(postion, radAngle, transformInfo);
        let stPt = CoordTRFUtil.transLocalPt2World(arcPtInfo.stPoint, radAngle, transformInfo);
        let midPt = CoordTRFUtil.transLocalPt2World(arcPtInfo.midPoint, radAngle, transformInfo);
        let endPt = CoordTRFUtil.transLocalPt2World(arcPtInfo.endPoint, radAngle, transformInfo);

        //做了变换后，原来圆弧的起点可能会变成终点，所以需要重新计算显示时的起点、终点角度
        let stVect = funcs.getVector(cnt, stPt);
        let midVect = funcs.getVector(cnt, midPt);
        let endVect = funcs.getVector(cnt, endPt);

        let disStAngle = stVect.angleFrmXAxisPositiveDir();
        let disEndAngle = endVect.angleFrmXAxisPositiveDir();

        let origZAxisV = arcVectInfo.stVector.crossMultiply(arcVectInfo.endVector);
        let curentZAxisV = stVect.crossMultiply(endVect);
        let dotMultiVal = curentZAxisV.dotMultiply(origZAxisV);
        if (dotMultiVal < 0) {
            //与原始圆弧反向
            disEndAngle = stVect.angleFrmXAxisPositiveDir();
            disStAngle = endVect.angleFrmXAxisPositiveDir();
        }

        var lenthDisScale = mapInfo.getLenthDisScale();

        let scalex = transformInfo.sx;
        let scaley = transformInfo.sy;

        let disXRadius = Math.abs(postion.radius * scalex * lenthDisScale);
        let disYRadius = postion.radius * scaley * lenthDisScale;
        let disYScale = Math.abs(scaley/scalex);


        let scrnCnt = CoordTRFUtil.world2Screen(cnt, mapInfo);
        let stAngleRad = Math.PI * 2 - funcs.degree2Radian(postion.stAngle);
        let endAngleRad = Math.PI * 2 - funcs.degree2Radian(postion.endAngle);

        let rotv = transformInfo.rotRad;
        map.save();
        map.translate(scrnCnt.x, scrnCnt.y);
        map.rotate(-rotv);
        map.scale(1,disYScale);
        map.beginPath();
        map.arc(0,0, disXRadius, stAngleRad, endAngleRad, true);
        map.restore();
        
        if (!forClip){
            Strokeutil.active(this._lineDef, this, map, mapInfo);
            FillUtil.active(this._fillDef, map, this, mapInfo, true);
        }
    }


    distance(tPoint, scaling, mapscale) {
        let wid = this._zone.width();
        let hgt = this._zone.height();
        if (isNaN(wid) || isNaN(hgt)) {
            this.setUseful(0);
            return -1;
        }
        if (!super.preCheckInScope(tPoint, scaling)) {
            return -1;
        }
        var postion = this.getPos();
        var cmpGap = super.getSelCmpGap(scaling, mapscale);
        if (funcs.chkPtInArcSec(postion, tPoint)) {
            let cnt = { x: postion.x, y: postion.y };
            let dis = Math.abs(funcs.distancePoint(cnt, tPoint, 1) - postion.radius);
            if (dis < global.ZERO_4E) {
                return 0;
            }
            else if (dis * scaling < cmpGap) {
                return dis;
            }
        }
        else {
            if (GlobalVar.easySelMode) {
                return postion.radius;
            }
            else {
                return -1;
            }
        }
    }

    calculateSubKind(tPoint, scaling, mapscale) {
        var nRefKind = 0;
        var cmpGap = super.getSelCmpGap(scaling, mapscale);
        var ptlst = this.getFeaturePtLst();
        //先检查当前鼠标位置是否足够临近特征点
        for (var i = 0; i < ptlst.length; i++) {
            var pt = ptlst[i];
            var lRst = funcs.distancePoint(pt, tPoint, scaling);
            if ((lRst <= cmpGap) && (lRst >= 0)) {
                nRefKind = i + 1;
                tPoint.clone(pt);
            }
        }

        if (nRefKind != 0) {
            return nRefKind;
        }

        var postion = this.getPos();
        if (funcs.chkPtInArcSec(postion, tPoint)) {
            let cnt = { x: postion.x, y: postion.y };
            let dis = Math.abs(funcs.distancePoint(cnt, tPoint, 1) - postion.radius);
            if (dis * scaling < cmpGap) {
                nRefKind = 1;
            }
        }
        return nRefKind;
    }

    calculateSubControlPoint(tPoint, scaling, mapscale) {
        let nRefKind = 0;
        let cmpGap = global.FocusSelGap;
        let ptlst = this.getControlPtLst();
        for (let i = 0; i < ptlst.length; i++) {
            let ctrlPt = ptlst[i];
            let dis = funcs.distancePoint({ x: ctrlPt.x, y: ctrlPt.y }, tPoint, scaling);
            if ((dis <= cmpGap) && (dis >= 0)) {
                nRefKind = ctrlPt.kind;
                tPoint.clone(ctrlPt);
            }
        }

        return nRefKind;
    }

    displayControlPoint(map, mapInfo) {
        let ptlst = this.getControlPtLst();
        for (let i = 0; i < ptlst.length; i++) {
            let ctrlPt = ptlst[i];
            var pt = CoordTRFUtil.world2Screen(ctrlPt, mapInfo);
            super.drawFocusPoint(map, pt.x, pt.y, "#ff00ff");
        }
    }

    calScope(mapscale) {
        if (this.getFinish() == 1) {
            this.resetToAnticlockwise();
        }
        let rect = funcs.calArcScope(this.getPosCopy());
        this._zone.clone(rect);
    }

    resetToAnticlockwise() {
        var postion = this.getPos();
        if (!postion.antiClockWise) {
            let tmp = postion.endAngle;
            postion.endAngle = postion.stAngle;
            postion.stAngle = tmp;
            postion.antiClockWise = true;
            let arcCtlPtInfo = funcs.getArcControlPoint(postion);
            this.stPoint.clone(arcCtlPtInfo.stPoint);
            this.midPoint.clone(arcCtlPtInfo.midPoint);
            this.endPoint.clone(arcCtlPtInfo.endPoint);
        }
    }

    getLocalZone() {
        let rect = new LGXCOM.LGXRect(0, 0, 0, 0);
        var postion = this.getPos();
        rect.left = (- postion.radius);
        rect.bottom = (- postion.radius);
        rect.right = (postion.radius);
        rect.top = (postion.radius);
        return rect;
    }

    getFeaturePtLst() {
        var ptlst = this.getControlPtLst();
        return ptlst;
    }

    getControlPtLst() {
        var postion = this.getPosCopy();
        let arcCtlPtInfo = funcs.getArcControlPoint(postion);
        var ptlst = [];

        //圆心
        let x = postion.x;
        let y = postion.y;
        let ctrlPt = { kind: 1, x, y };
        ptlst.push(ctrlPt);

        //起点
        ctrlPt = { kind: 2, x: arcCtlPtInfo.stPoint.x, y: arcCtlPtInfo.stPoint.y };
        ptlst.push(ctrlPt);

        //中间点
        ctrlPt = { kind: 3, x: arcCtlPtInfo.midPoint.x, y: arcCtlPtInfo.midPoint.y };
        ptlst.push(ctrlPt);

        ctrlPt = { kind: 4, x: arcCtlPtInfo.endPoint.x, y: arcCtlPtInfo.endPoint.y };
        ptlst.push(ctrlPt);
        return ptlst;
    }

    calControlPoint() {
        var postion = this.getPos();
        let rst = funcs.getArcStAndEndVector(postion);
        let arcSpanAngle = rst.stVector.angleByCrossMultiply2Another(rst.endVector);
        if (!postion.antiClockWise) {
            arcSpanAngle = -rst.endVector.angleByCrossMultiply2Another(rst.stVector);
        }
        let midVector = rst.stVector.rotateCopy(arcSpanAngle * 0.5);
        let stAngleRad = funcs.degree2Radian(postion.stAngle);
        let endAngleRad = funcs.degree2Radian(postion.endAngle);
        //起点
        this.stPoint.x = postion.x + postion.radius * Math.cos(stAngleRad);
        this.stPoint.y = postion.y + postion.radius * Math.sin(stAngleRad);

        //中间点
        let midDotAngle = funcs.degree2Radian(midVector.angleFrmXAxisPositiveDir());
        this.midPoint.x = postion.x + postion.radius * Math.cos(midDotAngle);
        this.midPoint.y = postion.y + postion.radius * Math.sin(midDotAngle);

        //终止点
        this.endPoint.x = postion.x + postion.radius * Math.cos(endAngleRad);
        this.endPoint.y = postion.y + postion.radius * Math.sin(endAngleRad);
    }

    movePosOffset(tOffset, modCmdInfo) {
        if (this._selKind < 1) {
            return;
        }
        var nRefKind = this._selKind;
        if (nRefKind == 1) {
            this.translate(tOffset, modCmdInfo.mapscale);
            this.calControlPoint();
        }
        else if (nRefKind == 2) {
            this.stPoint.x += tOffset.x;
            this.stPoint.y += tOffset.y;
        }
        else if (nRefKind == 3) {
            this.midPoint.x += tOffset.x;
            this.midPoint.y += tOffset.y;
        }
        else if (nRefKind == 4) {
            this.endPoint.x += tOffset.x;
            this.endPoint.y += tOffset.y;
        }
        this.calculateArcInfo();
        this.calScope(modCmdInfo.mapscale);
    }

    calculateArcInfo() {
        var position = this.getPos();

        //起点到中间特征点
        let st2midPoint = funcs.getMidPoint(this.stPoint, this.midPoint);
        let st2midVct = funcs.getVector(this.stPoint, this.midPoint);
        let vertical2St2MidVct = st2midVct.rotateCopy(90);

        //中间特征点到终点
        let mid2EndPoint = funcs.getMidPoint(this.midPoint, this.endPoint);
        let mid2EndVct = funcs.getVector(this.midPoint, this.endPoint);
        let vertical2Mid2EndVct = mid2EndVct.rotateCopy(90);
        let interPoint = funcs.getTwoLineInterPos(st2midPoint, vertical2St2MidVct, mid2EndPoint, vertical2Mid2EndVct);
        if (!interPoint) {
            return;
        }
        position.x = interPoint.x;
        position.y = interPoint.y;
        position.radius = funcs.distancePoint(interPoint, this.stPoint, 1);

        let stLineVct = funcs.getVector(interPoint, this.stPoint);
        position.stAngle = stLineVct.angleFrmXAxisPositiveDir();

        let endLineVct = funcs.getVector(interPoint, this.endPoint);
        position.endAngle = endLineVct.angleFrmXAxisPositiveDir();

        let rotAngle = st2midVct.angleByCrossMultiply2Another(mid2EndVct);
        if (rotAngle > 180) {
            position.antiClockWise = false;
        }
        else {
            position.antiClockWise = true;
        }

        this.calControlPoint(true);
    }

    getMainFeaturePTLst(tFeaturePTLst,transformInfo) {
        var posList = this.getFeaturePtLst();
        var pt = posList[0];
        let featurePT = this.convertPt2World(pt,transformInfo);
        tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.center });

        for (var i = 1; i < posList.length; i++) {
            pt = posList[i];
            featurePT = this.convertPt2World(pt,transformInfo);
            tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.end });
        }
    }

    getSubFeaturePTLst(tFeaturePTLst, mousePoint,transformInfo) {
        let position = this.getPosCopy();
        let tmpCnt = this.convertPt2World(position,transformInfo);
        position.x = tmpCnt.x;
        position.y = tmpCnt.y;
        let interPtList = funcs.getLineInterCircle(mousePoint, tmpCnt, position);
        if (!interPtList || (interPtList && interPtList.length == 0)) {
            return;
        }

        if (interPtList.length == 1) {
            let pt = interPtList[0];
            tFeaturePTLst.push({ pt, kind: LGXEnums.AuxPointKind.commonPt });
        }
        else if (interPtList.length == 2) {
            let pt0 = interPtList[0];
            let pt1 = interPtList[1];
            let dis0 = funcs.distancePoint(pt0, mousePoint, 1);
            let dis1 = funcs.distancePoint(pt1, mousePoint, 1);
            let dstPt = pt0;
            if (dis1 < dis0) {
                dstPt = pt1;
            }
            tFeaturePTLst.push({ pt: dstPt, kind: LGXEnums.AuxPointKind.commonPt });
        }
    }

    assignInfo(info) {
        super.assignInfo(info);
    }

    modifyAttribute(info, mapscale) {
        super.modifyAttribute(info, mapscale);
        this.calScope(mapscale);
    }

    toInfo() {
        var info = new arcUnit();
        this.toInfo4InheritClass(info);
        info.radius = this._position.radius;
        info.x = this._position.x;
        info.y = this._position.y;
        info.stAngle = this._position.stAngle;
        info.endAngle = this._position.endAngle;
        info.antiClockWise = this._position.antiClockWise;
        return info;
    }

    modifyCoord(propName, propVal, mapscale) {
        var position = this.getPos();
        if (propName == "cnt") {
            position.x = parseFloat(propVal.x);
            position.y = parseFloat(propVal.y);
        }
        else if (propName == "radius") {
            position.radius = parseFloat(propVal);
        }
        else if (propName == "stangle") {
            position.stAngle = parseFloat(propVal);
        }
        else if (propName == "endangle") {
            position.endAngle = parseFloat(propVal);
        }
        this.calControlPoint();
        this.notifyToObserver();
        this.calScope(mapscale);
    }

    getCoordInfo() {
        let graphPropDef = this.getCoordPropDef();
        let tableData = [];
        var position = this.getPos();
        let x = position.x;
        let y = position.y;
        let cntObj = {
            propName: 'cnt',
            propLabel: '圆心',
            propValue: { x, y }
        };
        tableData.push(cntObj);

        let radisObj = {
            propName: 'radius',
            propLabel: '短轴',
            propValue: position.radius
        };
        tableData.push(radisObj);

        let stangleObj = {
            propName: 'stangle',
            propLabel: '起始角',
            propValue: position.stAngle
        };
        tableData.push(stangleObj);

        let endangleObj = {
            propName: 'endangle',
            propLabel: '终止角',
            propValue: position.endAngle
        };
        tableData.push(endangleObj);

        let tableForm = {
            'tableData': tableData
        };
        return { graphPropDef, tableForm };
    }

    getCoordPropDef() {
        let graphPropDef = {
            cnt: {
                vtype: global.Pt_CoordType,
                range: { min: 1, max: 300 },
            },
            radius: {
                vtype: global.Single_CoordType,
                range: { min: 1, max: 300 },
            },
            stangle: {
                vtype: global.Single_CoordType,
                range: { min: 0, max: 360 },
            },
            endangle: {
                vtype: global.Single_CoordType,
                range: { min: 0, max: 360 },
            }
        }
        return graphPropDef;
    }


    getDimDatumFeatureLst() {
        let rstArr = [];

        let position = this.getPos();
        //图形中心
        let idkey = 1;
        let data = { x: position.x, y: position.y };
        let info = { type: LGXEnums.DimDatumType.center, data, id: idkey++ };
        rstArr.push(info);

        let idxVal = 0;

        let x = this.stPoint.x;
        let y = this.stPoint.y;
        data = { idx: idxVal++, x, y };
        info = { type: LGXEnums.DimDatumType.vertex, data, id: idkey++ };
        rstArr.push(info);

        x = this.endPoint.x;
        y = this.endPoint.y;
        data = { idx: idxVal++, x, y };
        info = { type: LGXEnums.DimDatumType.vertex, data, id: idkey++ };
        rstArr.push(info);

        x = this.midPoint.x;
        y = this.midPoint.y;
        data = { idx: idxVal++, x, y };
        info = { type: LGXEnums.DimDatumType.vertex, data, id: idkey++ };
        rstArr.push(info);


        //顶点特征
        idkey++
        x = position.x;
        y = position.y + position.radius;
        data = { idx: idxVal++, x, y };
        if (funcs.chkPtInArcSec(position, data)) {
            let info = { type: LGXEnums.DimDatumType.vertex, data, id: idkey };
            rstArr.push(info);
        }


        idkey++
        x = position.x + position.radius;
        y = position.y;
        data = { idx: idxVal++, x, y };
        if (funcs.chkPtInArcSec(position, data)) {
            let info = { type: LGXEnums.DimDatumType.vertex, data, id: idkey };
            rstArr.push(info);
        }

        idkey++
        x = position.x;
        y = position.y - position.radius;
        data = { idx: idxVal++, x, y };
        if (funcs.chkPtInArcSec(position, data)) {
            let info = { type: LGXEnums.DimDatumType.vertex, data, id: idkey };
            rstArr.push(info);
        }

        idkey++
        x = position.x - position.radius;
        y = position.y;
        data = { idx: idxVal++, x, y };
        if (funcs.chkPtInArcSec(position, data)) {
            let info = { type: LGXEnums.DimDatumType.vertex, data, id: idkey };
            rstArr.push(info);
        }
        return rstArr;
    }

    getPosCopy() {
        let pos = new Coord.ArcPos();
        pos.clone(this._position);
        return pos;
    }

    onChgDimValue(dimGraph, oldValue, newValue) {
        console.log("arc graph onChgDimValue******");
        let svc = new ArcDimChg(this);
        svc.onChgDimValue(dimGraph, oldValue, newValue);
    }

    onDimBaseChged(dimGraph) {
        console.log("arc onDimBaseChged******");
        let svc = new ArcDimBaseChange(this);
        svc.onBaseChanged(dimGraph);
    }

    setDisAuxPoint(mousePt) {
        this.disAuxPoint.clone(mousePt);
    }

    setStPoint(pt) {
        this.stPoint.clone(pt);
    }
    setMidPoint(pt) {
        this.midCtrlPoint.clone(pt);
    }
    setEndPoint(pt) {
        console.log("src set end point***************");
        this.endPoint.clone(pt);
        let st2midVect = funcs.getVector(this.stPoint, this.midCtrlPoint);
        let st2midVectVertical = st2midVect.rotateCopy(90);
        let midPt_st2mid = funcs.getMidPoint(this.stPoint, this.midCtrlPoint);

        let mid2endVect = funcs.getVector(this.midCtrlPoint, this.endPoint);
        let mid2EndVectVertical = mid2endVect.rotateCopy(90);
        let midPt_mid2End = funcs.getMidPoint(this.midCtrlPoint, this.endPoint);

        let interPt = funcs.getTwoLineInterPos(midPt_st2mid, st2midVectVertical, midPt_mid2End, mid2EndVectVertical);
        if (!interPt) {
            return;
        }

        var position = this.getPos();
        let rotAngle = st2midVect.angleByCrossMultiply2Another(mid2endVect);
        if (rotAngle > 180) {
            position.antiClockWise = false;
        }
        else {
            position.antiClockWise = true;
        }

        position.x = interPt.x;
        position.y = interPt.y;
        position.radius = funcs.distancePoint(interPt, this.stPoint);

        let stvect = funcs.getVector(interPt, this.stPoint);
        position.stAngle = stvect.angleFrmXAxisPositiveDir();

        let endvect = funcs.getVector(interPt, this.endPoint);
        position.endAngle = endvect.angleFrmXAxisPositiveDir();
    }

    getLocalOrigin() {
        let pt = { x: 0, y: 0 };
        pt.x = this._position.x;
        pt.y = this._position.y;
        return pt;
    }

    //复制粘贴时，从复制源对象复制属性到本图形对应属性----虚函数，由实体继承类实现
    copySubPropFromBuf(bufInfo,tx,ty){
        this.close = bufInfo.close;
        this.copyCommnonPropFromBuf(bufInfo,tx,ty);
    }
}

export default { ArcGraph }
